<template>
	<!-- 维保单位 添加/编辑/详情 -->
	<div class="compile">
		<el-dialog :close-on-click-modal='false' :append-to-body='true' :before-close='close' :close-on-press-escape='false'
		 :title="title" :visible.sync="addAndCompileShow">
			<el-form :model="form" :rules="rules" ref="form" v-loading='isLoading'>
				<el-row>
					<div class="textLeft titleMessNow">单位信息</div>
				</el-row>
				<el-row>
					<el-col :span="10" :offset='1'>
						<el-form-item label="单位名称:" :label-width="formLabelWidth" prop="groupName">
							<el-input size="mini" v-model="form.groupName" autocomplete="off" clearable :disabled='detailDisable'></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="10" :offset='2'>
						<el-form-item label="社会信用码:" :label-width="formLabelWidth" prop="socialCode">
							<el-input size="mini" v-model="form.socialCode" autocomplete="off" clearable :disabled='detailDisable'></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="10" :offset='1'>
						<el-form-item label="法人:" :label-width="formLabelWidth" prop="legalPeo">
							<el-input size="mini" v-model="form.legalPeo" autocomplete="off" clearable :disabled='detailDisable'></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="10" :offset='2'>
						<el-form-item label="法人电话:" :label-width="formLabelWidth" prop="legalPeoPhone">
							<el-input size="mini" v-model="form.legalPeoPhone" autocomplete="off" clearable :disabled='detailDisable'></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="10" :offset='1'>
						<el-form-item label="主要负责人" :label-width="formLabelWidth" prop="principalPeo">
							<el-input size="mini" v-model="form.principalPeo" autocomplete="off" clearable :disabled='detailDisable'></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="10" :offset='2'>
						<el-form-item label="负责人电话:" :label-width="formLabelWidth" prop="principalPeoPhone">
							<el-input size="mini" v-model="form.principalPeoPhone" autocomplete="off" clearable :disabled='detailDisable'></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row v-if="title !== '编辑维保单位'">
					<el-col :span="10" :offset='1'>
						<el-form-item label="系统对接账户:" :label-width="formLabelWidth" prop="account">
							<el-input size="mini" v-model="form.account" autocomplete="off" clearable :disabled='detailDisable'></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="10" :offset='2'>
						<el-form-item label="系统对接令牌:" :label-width="formLabelWidth" prop="token">
							<el-input size="mini" v-model="form.token" autocomplete="off" clearable :disabled='detailDisable'></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="10" :offset='1'>
						<el-form-item label="单位电话:" :label-width="formLabelWidth" prop="groupPhone">
							<el-input size="mini" v-model="form.groupPhone" autocomplete="off" clearable :disabled='detailDisable'></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="10" :offset="1">
						<el-form-item label="营业执照:" :label-width="formLabelWidth" prop="pactAffix">
							<el-upload :on-preview="upLoadPreview" action="" accept=".jpg,.jpeg,.png" :file-list="fileList" :on-change="upLoadChange"
							 :on-remove="upLoadRemove" :auto-upload="false" list-type="picture" name="upfile" :disabled='detailDisable'>
								<el-button size="mini" type="primary" :disabled='detailDisable'>点击上传</el-button>
								<div slot="tip" class="upLoadText">只能上传JPG/PNG/JPEG图片,大小不超过800kb/最多上传1张</div>
							</el-upload>
						</el-form-item>
					</el-col>
					<el-col :span="10" :offset="2">
						<el-form-item label="特种改造许可证:" :label-width="formLabelWidth" prop="pactAffix1">
							<el-upload :on-preview="upLoadPreview" action="" accept=".jpg,.jpeg,.png" :file-list="fileList1" :on-change="upLoadChange1"
							 :on-remove="upLoadRemove1" :auto-upload="false" list-type="picture" name="upfile" :disabled='detailDisable'>
								<el-button size="mini" type="primary" :disabled='detailDisable'>点击上传</el-button>
								<div slot="tip" class="upLoadText">只能上传JPG/PNG/JPEG图片,大小不超过800kb/最多上传1张</div>
							</el-upload>
						</el-form-item>
					</el-col>
				</el-row>
				<!-- 注册地址 -->
				<el-row>
					<div class="textLeft titleMessNow">注册地址</div>
				</el-row>
				<el-row>
					<el-col :span="10" :offset='1'>
						<el-form-item label="省份" :label-width="formLabelWidth" prop="signProvince">
							<el-select size="mini" @change="changeArr(1)" @focus="getProvince" v-model="form.signProvince" placeholder="请选择省份"
							 :disabled="detailDisable" clearable>
								<el-option v-for="item in signProvinceArr" :key="item.address_code" :label="item.name" :value="item.address_code">
								</el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="10" :offset='2'>
						<el-form-item label="城市" :label-width="formLabelWidth" prop="signCity">
							<el-select size="mini" @change="changeArr(2)" v-model="form.signCity" placeholder="请选择城市" :disabled="signCityDis"
							 clearable>
								<el-option v-for="item in signCityArr" :key="item.address_code" :label="item.name" :value="item.address_code">
								</el-option>
							</el-select>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="10" :offset='1'>
						<el-form-item label="区/县" :label-width="formLabelWidth" prop="signArea">
							<el-select size="mini" @change="changeArr(3)" v-model="form.signArea" placeholder="请选择区/县" :disabled=" signAreaDis"
							 clearable>
								<el-option v-for="item in signAreaArr" :key="item.address_code" :label="item.name" :value="item.address_code">
								</el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="10" :offset='2'>
						<el-form-item label="街道" :label-width="formLabelWidth" prop="signStreet">
							<el-select size="mini" v-model="form.signStreet" placeholder="请选择街道" :disabled="signStreetDis" clearable>
								<el-option v-for="item in signStreetArr" :key="item.address_code" :label="item.name" :value="item.address_code">
								</el-option>
							</el-select>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="10" :offset='1'>
						<el-form-item label="详细地址:" :label-width="formLabelWidth" prop="detailAdress">
							<el-input size="mini" v-model="form.detailAdress" autocomplete="off" clearable :disabled='detailDisable'></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<!-- 注册地址 -->
				<el-row>
					<div class="textLeft titleMessNow">维保网点地址</div>
				</el-row>
				<el-row>
					<el-col :span="10" :offset='1'>
						<el-form-item label="维保网点地址:" :label-width="formLabelWidth" prop="networkAddress">
							<el-input size="mini" v-model="form.networkAddress" autocomplete="off" clearable :disabled='detailDisable'></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="10" :offset='2'>
						<el-form-item label="24小时电话:" :label-width="formLabelWidth" prop="allDayNum">
							<el-input size="mini" v-model="form.allDayNum" autocomplete="off" clearable :disabled='detailDisable'></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="10" :offset='1'>
						<el-form-item label="省份" :label-width="formLabelWidth" prop="networkProvince">
							<el-select size="mini" @change="changeArr1(1)" @focus="getProvince" v-model="form.networkProvince" placeholder="请选择省份"
							 :disabled="detailDisable" clearable>
								<el-option v-for="item in networkProvinceArr" :key="item.address_code" :label="item.name" :value="item.address_code">
								</el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="10" :offset='2'>
						<el-form-item label="城市" :label-width="formLabelWidth" prop="networkCity">
							<el-select size="mini" @change="changeArr1(2)" v-model="form.networkCity" placeholder="请选择城市" :disabled="networkCityDis"
							 clearable>
								<el-option v-for="item in networkCityArr" :key="item.address_code" :label="item.name" :value="item.address_code">
								</el-option>
							</el-select>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="10" :offset='1'>
						<el-form-item label="区/县" :label-width="formLabelWidth" prop="networkArea">
							<el-select size="mini" @change="changeArr1(3)" v-model="form.networkArea" placeholder="请选择区/县" :disabled="networkAreaDis"
							 clearable>
								<el-option v-for="item in networkAreaArr" :key="item.address_code" :label="item.name" :value="item.address_code">
								</el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="10" :offset='2'>
						<el-form-item label="街道" :label-width="formLabelWidth" prop="networkStreet">
							<el-select size="mini" v-model="form.networkStreet" placeholder="请选择街道" :disabled="networkStreetDis" clearable>
								<el-option v-for="item in networkStreetArr" :key="item.address_code" :label="item.name" :value="item.address_code">
								</el-option>
							</el-select>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="10" :offset='1'>
						<el-form-item label="网点负责人:" :label-width="formLabelWidth" prop="networkprincipalPeo">
							<el-input size="mini" v-model="form.networkprincipalPeo" autocomplete="off" clearable :disabled='detailDisable'></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="10" :offset='2'>
						<el-form-item label="负责人电话:" :label-width="formLabelWidth" prop="networkprincipalPeoPhone">
							<el-input size="mini" v-model="form.networkprincipalPeoPhone" autocomplete="off" clearable :disabled='detailDisable'></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<!-- 匹配结果 -->
				<div v-if="detailDisable">
					<el-row>
						<el-col :span="16" :offset='1'>
							<el-form-item label="更新状态:" :label-width="formLabelWidth">
								<img src="" alt="">
							</el-form-item>
						</el-col>
					</el-row>
					<el-row>
						<div class="textLeft titleMessNow">匹配结果</div>
					</el-row>
					<el-row>
						<el-col :span="16" :offset='1'>
							<el-form-item label="更新状态:" :label-width="formLabelWidth">
								<el-input size="mini" v-model="updataType" autocomplete="off" clearable :disabled='detailDisable'></el-input>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row>
						<el-col :span="16" :offset='1'>
							<el-form-item label="最后更新时间" :label-width="formLabelWidth">
								<el-date-picker size="mini" v-model="lastUpdataTime" type="date" placeholder="请选择最后更新时间" format="yyyy-MM-dd HH:mm:ss"
								 value-format="yyyy-MM-dd HH:mm:ss" clearable :disabled='detailDisable'>
								</el-date-picker>
							</el-form-item>
						</el-col>
					</el-row>

					<div class="div" v-if="roleId == 0">
						<el-row>
							<div class="textLeft titleMessNow">备案原始数据</div>
						</el-row>
						<el-row>
							<el-col :span="16" :offset="1">
								<div class="copy" id="content">
									{{recordCon}}
								</div>
								<el-button type="primary" style="margin-left: 170px;margin-top:15px" @click="copy">复制所有请求信息</el-button>
							</el-col>
						</el-row>
						<el-row>
							<el-col :span="16" :offset="1">
								<div class="copy" id="content1">
									{{recordCon1}}
								</div>
								<el-button type="primary" style="margin-left: 170px;margin-top:15px" @click="copy1">复制所有返回信息</el-button>
							</el-col>
						</el-row>
					</div>
				</div>
			</el-form>

			<div slot="footer" class="dialog-footer">
				<el-button @click="close(2)">取 消</el-button>
				<el-button type="primary" @click="submit('form')" v-loading='ensureBtn' v-if="!detailDisable">确 定</el-button>
			</div>
		</el-dialog>
		<el-dialog custom-class="imgDialogShow" :visible.sync="imgDialogShow" :append-to-body='true' :before-close='closeImg'>
			<img :src="dialogImgUrl" alt="">
		</el-dialog>
	</div>
</template>

<script>
	import {
		axiosPost,
		axiosGet,
		loadFn,
		axiosChange,
	} from "@/common.js"
	import {
		groupName,
		socialCode,
		legalPeo,
		legalPeoPhone,
		principalPeo,
		principalPeoPhone,
		account,
		token,
		groupPhone,
		signProvince,
		signCity,
		signArea,
		signStreet,
		detailAdress,
		networkAddress,
		allDayNum,
		networkProvince,
		networkCity,
		networkArea,
		networkStreet,
		networkprincipalPeo,
		networkprincipalPeoPhone,
	} from "./rule.js"
	export default {
		props: ['addAndCompileShow', 'isAddOrComp', 'rowId'],
		mounted() {
			if (this.title == '添加维保单位') {
				this.isLoading = false
			}
		},
		data() {
			var valiPic = (rule, value, callback) => {
				if (this.fileList.length === 0) {
					callback(new Error('请上传营业执照'));
				} else {
					callback();
				}
			};
			var valiPic1 = (rule, value, callback) => {
				if (this.fileList1.length === 0) {
					callback(new Error('请上传特种许可改造证'));
				} else {
					callback();
				}
			};
			return {
				formLabelWidth: '120px',
				form: {
					groupName: '',
					socialCode: '',
					legalPeo: '',
					legalPeoPhone: '',
					principalPeo: '',
					principalPeoPhone: '',
					account: '',
					token: '',
					groupPhone: '',
					signProvince: '',
					signCity: '',
					signArea: '',
					signStreet: '',
					detailAdress: '',
					networkAddress: '',
					allDayNum: '',
					networkProvince: '',
					networkCity: '',
					networkArea: '',
					networkStreet: '',
					networkprincipalPeo: '',
					networkprincipalPeoPhone: '',
				},
				ensureBtn: false,
				rules: {
					groupName,
					socialCode,
					legalPeo,
					legalPeoPhone: [{
						required: true,
						trigger: 'blur',
						validator: legalPeoPhone,
					}],
					principalPeo,
					principalPeoPhone: [{
						required: true,
						trigger: 'blur',
						validator: principalPeoPhone,
					}],
					account,
					token,
					pactAffix: [{
						required: true,
						trigger: 'blur',
						validator: valiPic
					}],
					pactAffix1: [{
						required: true,
						trigger: 'blur',
						validator: valiPic1
					}],
					groupPhone: [{
						required: true,
						trigger: 'blur',
						validator: groupPhone,
					}],
					signProvince,
					signCity,
					signArea,
					signStreet,
					detailAdress,
					networkAddress,
					allDayNum: [{
						required: true,
						trigger: 'blur',
						validator: allDayNum,
					}],
					networkProvince,
					networkCity,
					networkArea,
					networkStreet,
					networkprincipalPeo,
					networkprincipalPeoPhone: [{
						required: true,
						trigger: 'blur',
						validator: networkprincipalPeoPhone,
					}],
				},
				fileList: [],
				fileList1: [],
				signProvinceArr: [],
				networkProvinceArr: [],
				signCityDis: true,
				signAreaDis: true,
				signStreetDis: true,
				networkCityDis: true,
				networkAreaDis: true,
				networkStreetDis: true,
				upImg1: '',
				upImg2: '',
				isLoading: true,
				dialogImgUrl: '',
				imgDialogShow: false,
				updataType: '',
				lastUpdataTime: '',
				recordCon: '',
				recordCon1: '',
			}
		},
		computed: {
			detailDisable() {
				if (this.title == '维保单位详情') {
					return true
				} else {
					return false
				}
			},
			title() {
				if (this.isAddOrComp == 1) {
					return '添加维保单位'
				} else if (this.isAddOrComp == 2) {
					this.getCompileList()
					return '编辑维保单位'
				} else {
					this.getCompileList()
					return '维保单位详情'
				}
			},
			roleId() {
				if (localStorage.role) {
					return JSON.parse(localStorage.role).id
				} else {
					return ''
				}
			},
			//注册地址
			signCityArr() {
				if (this.signProvinceArr.length != 0 && this.form.signProvince) {
					return this.signProvinceArr.find((item) => {
						return item.address_code === this.form.signProvince
					}).children;
				} else {
					return []
				}
			},
			//网点
			networkCityArr() {
				if (this.networkProvinceArr.length != 0 && this.form.networkProvince) {
					return this.networkProvinceArr.find((item) => {
						return item.address_code === this.form.networkProvince
					}).children;
				} else {
					return []
				}
			},
			//注册地址
			signAreaArr() {
				if (this.signCityArr.length != 0 && this.form.signCity) {
					return this.signCityArr.find((item) => {
						return item.address_code == this.form.signCity
					}).children
				} else {
					return []
				}
			},
			//网点
			networkAreaArr() {
				if (this.networkCityArr.length != 0 && this.form.networkCity) {
					return this.networkCityArr.find((item) => {
						return item.address_code == this.form.networkCity
					}).children
				} else {
					return []
				}
			},
			//注册地址
			signStreetArr() {
				if (this.signAreaArr.length != 0 && this.form.signArea) {
					return this.signAreaArr.find((item) => {
						return item.address_code == this.form.signArea
					}).children
				} else {
					return []
				}
			},
			//网点地址
			networkStreetArr() {
				if (this.networkAreaArr.length != 0 && this.form.networkArea) {
					return this.networkAreaArr.find((item) => {
						return item.address_code == this.form.networkArea
					}).children
				} else {
					return []
				}
			},
		},
		methods: {
			copy() {
				/* 创建range对象   */
				const range = document.createRange();
				range.selectNode(document.getElementById('content'));
				/* 窗口的selection对象，表示用户选择的文本 */
				const selection = window.getSelection();
				if (selection.rangeCount > 0) selection.removeAllRanges(); // 将已经包含的已选择的对象清除掉
				selection.addRange(range); // 将要复制的区域的range对象添加到selection对象中
				document.execCommand('copy'); // 执行copy命令，copy用户选择的文本
			},
			copy1() {
				/* 创建range对象   */
				const range = document.createRange();
				range.selectNode(document.getElementById('content1'));
				/* 窗口的selection对象，表示用户选择的文本 */
				const selection = window.getSelection();
				if (selection.rangeCount > 0) selection.removeAllRanges(); // 将已经包含的已选择的对象清除掉
				selection.addRange(range); // 将要复制的区域的range对象添加到selection对象中
				document.execCommand('copy'); // 执行copy命令，copy用户选择的文本
			},
			//三级变化
			changeArr(value) {
				if (value == 1) {
					this.form.signCity = ''
					this.form.signArea = ''
					this.form.signStreet = ''
					this.signCityDis = false
					this.signAreaDis = true
					this.signStreetDis = true
				} else if (value == 2) {
					this.form.signArea = ''
					this.form.signStreet = ''
					this.signAreaDis = false
				} else if (value == 3) {
					this.form.signStreet = ''
					this.signStreetDis = false
				}
				if (!!!this.form.signProvince) {
					this.signCityDis = true
					this.signAreaDis = true
					this.signStreetDis = true
				}
				if (!!!this.form.signCity) {
					this.signAreaDis = true
					this.signStreetDis = true
				}
				if (!!!this.form.signArea) {
					this.signStreetDis = true
				}
			},
			//网点三级变化
			changeArr1(value) {
				if (value == 1) {
					this.form.networkCity = ''
					this.form.networkArea = ''
					this.form.networkStreet = ''
					this.networkCityDis = false
					this.networkAreaDis = true
					this.networkStreetDis = true
				} else if (value == 2) {
					this.form.networkArea = ''
					this.form.networkStreet = ''
					this.networkAreaDis = false
					this.networkStreetDis = true
				} else if (value == 3) {
					this.form.networkStreet = ''
					this.networkStreetDis = false
				}
				if (!!!this.form.networkProvince) {
					this.networkCityDis = true
					this.networkAreaDis = true
					this.networkStreetDis = true
				}
				if (!!!this.form.networkCity) {
					this.networkAreaDis = true
					this.networkStreetDis = true
				}
				if (!!!this.form.networkArea) {
					this.networkStreetDis = true
				}
			},
			//获取三级联动数据
			getProvince() {
				axiosGet('/user/address', {}, (res) => {
					if (res.code == 0) {
						this.signProvinceArr = res.detail
						this.networkProvinceArr = res.detail
					} else {
						this.$message.error(res.detail.result)
					}
				})
			},
			//点击图片时触发
			upLoadPreview(file) {
				this.imgDialogShow = true
				this.dialogImgUrl = file.url
			},
			//上传文件之前触发
			upLoadChange(file, fileList) {
				const isLt2M = file.size / 1024 < 800;
				if (file.name.split(".")[1] != "jpg" && file.name.split(".")[1] != "png" && file.name.split(".")[1] != "jpeg") {
					this.$message.error('只能上传JPG/PNG/JPEG格式图片');
					this.fileList = fileList.slice(0, -1);
					return
				}
				if (!isLt2M) {
					this.$message.error('上传图片大小不能超过 800kb!,请重新上传');
					this.fileList = fileList.slice(0, -1);
					return
				}
				this.fileList = fileList.slice(-1);
			},
			upLoadChange1(file, fileList) {
				const isLt2M = file.size / 1024 < 800;
				if (file.name.split(".")[1] != "jpg" && file.name.split(".")[1] != "png" && file.name.split(".")[1] != "jpeg") {
					this.$message.error('只能上传JPG/PNG/JPEG格式图片');
					this.fileList1 = fileList.slice(0, -1);
					return
				}
				if (!isLt2M) {
					this.$message.error('上传图片大小不能超过 800kb!,请重新上传');
					this.fileList1 = fileList.slice(0, -1);
					return
				}
				this.fileList1 = fileList.slice(-1);
			},
			//删除文件之前的函数
			upLoadRemove(file, fileList) {
				this.fileList = fileList;
				console.log(this.fileList)
			},
			upLoadRemove1(file, fileList) {
				this.fileList1 = fileList;
				console.log(this.fileList1)
			},
			//上传照片
			uploadImage(imgList) {
				let url = null;
				if (imgList.length > 0) {
					const formData = new FormData();
					formData.append("upfile", imgList[0].raw)
					return this.$axios({
						url: "/utils/upload/",
						method: "post",
						data: formData
					})
				} else {
					return Promise.reject('no image');
				}
			},
			async oprationUintPub(value) {
				let url = ''
				let method = ''
				let rowId = this.rowId ? this.rowId : ''
				if (this.fileList[0].raw) {
					const uploadRes = await this.uploadImage(this.fileList)
					this.upImg1 = uploadRes.code === 0 ? uploadRes.detail : ''
				} else {
					this.upImg1 = this.fileList[0].url;
				}
				if (this.fileList1[0].raw) {
					const uploadRes = await this.uploadImage(this.fileList1)
					this.upImg2 = uploadRes.code === 0 ? uploadRes.detail : ''
				} else {
					this.upImg2 = this.fileList1[0].url
				}
				let data = {
					name: this.form.groupName, //单位名称
					unified_code: this.form.socialCode, //社会统一信用码
					legal_person: this.form.legalPeo, //法人
					legal_phone: this.form.legalPeoPhone, //法人电话
					person_in_charge: this.form.principalPeo, //主要负责人
					person_in_charge_phone: this.form.principalPeoPhone, //负责人电话
					link_account: this.form.account,
					link_token: this.form.token,
					company_telephone: this.form.groupPhone, //单位电话
					business_lic: this.upImg1,
					lic_pic: this.upImg2,
					username: '',
					pwd: '',
					register_province: this.form.signProvince, //注册省
					register_city: this.form.signCity, //注册市
					register_county: this.form.signArea, //注册区
					register_street: this.form.signStreet, //注册街道
					register_address: this.form.detailAdress, //详细地址
					office_address: this.form.networkAddress, //维保网点地址
					emergency_phone: this.form.allDayNum, //24小时应急值守电话
					province_code: this.form.networkProvince, //网点省
					city_code: this.form.networkCity, //网点市
					county_code: this.form.networkArea, //网点区
					street_code: this.form.networkStreet, //网点街道
					office_main_person: this.form.networkprincipalPeo, //网点负责人
					office_main_person_phone: this.form.networkprincipalPeoPhone, //网点负责人手机
					company_type: 100,
				}

				if (value == 1) {
					url = '/user/company/'
					method = 'post'
				} else {
					url = '/user/company/' + rowId + '/'
					method = 'put'
				}

				setTimeout(() => {
					axiosChange(url, method, data, (res) => {
						this.ensureBtn = false
						if (res.code == 0) {
							this.$message({
								type: 'success',
								message: '操作成功'
							})
							this.close(1)
						} else {
							this.$message.error(res.detail.result)
						}
					})
				}, 10)
			},
			//获取编辑 详情数据
			getCompileList() {
				let rowId = this.rowId ? this.rowId : ''
				let url = '/user/company/' + rowId + '/'
				axiosGet(url, {}, (res) => {
					this.isLoading = false
					if (res.code == 0) {
						this.form.groupName = res.detail.name //单位名称
						this.form.socialCode = res.detail.unified_code //社会统一信用码
						this.form.legalPeo = res.detail.legal_person //法人
						this.form.legalPeoPhone = res.detail.legal_phone //法人电话
						this.form.principalPeo = res.detail.person_in_charge //主要负责人
						this.form.principalPeoPhone = res.detail.person_in_charge_phone //负责人电话
						this.form.account = res.detail.link_account
						this.form.token = res.detail.link_token
						this.form.groupPhone = res.detail.company_telephone //单位电话
						this.form.detailAdress = res.detail.register_address //详细地址
						this.form.networkAddress = res.detail.website.office_address //维保网点地址
						this.form.allDayNum = res.detail.website.emergency_phone //24小时应急值守电话
						this.form.networkprincipalPeo = res.detail.website.office_main_person //网点负责人
						this.form.networkprincipalPeoPhone = res.detail.website.office_main_person_phone //网点负责人手机
						this.fileList = [{
							name: '',
							url: res.detail.business_lic
						}]
						this.fileList1 = [{
							name: '',
							url: res.detail.lic_pic
						}]
						this.signProvinceArr = [{
							address_code: res.detail.register_province,
							name: res.detail.register_info.province_name,
							children: [{
								address_code: res.detail.register_city,
								name: res.detail.register_info.city_name,
								children: [{
									address_code: res.detail.register_county,
									name: res.detail.register_info.county_name,
									children: [{
										address_code: res.detail.register_street,
										name: res.detail.register_info.street_name,
									}]
								}]
							}]
						}]
						this.form.signProvince = res.detail.register_province
						this.form.signCity = res.detail.register_city
						this.form.signArea = res.detail.register_county
						this.form.signStreet = res.detail.register_street
						this.networkProvinceArr = [{
							address_code: res.detail.website.province_num,
							name: res.detail.website.province_code,
							children: [{
								address_code: res.detail.website.city_num,
								name: res.detail.website.city_code,
								children: [{
									address_code: res.detail.website.county_num,
									name: res.detail.website.county_code,
									children: [{
										address_code: res.detail.website.street_num,
										name: res.detail.website.street_code,
									}]
								}]
							}]
						}]
						this.form.networkProvince = res.detail.website.province_num
						this.form.networkCity = res.detail.website.city_num
						this.form.networkArea = res.detail.website.county_num
						this.form.networkStreet = res.detail.website.street_num

						let message = !!res.detail.record.rec_status ? '更新成功' : '更新失败'
						this.updataType = message + '/' + res.detail.record.msg
						this.lastUpdataTime = res.detail.record.end_time
						if (Object.keys(res.detail.record).length > 0) {
							if (!!res.detail.record.ret_info) {
								this.recordCon1 = res.detail.record.ret_info
							} else {
								this.recordCon1 = {}
							}
							if (!!res.detail.record.reg_info) {
								this.recordCon = res.detail.record.reg_info
							} else {
								this.recordCon = {}
							}
						}
					} else {
						this.$message.error(res.detail.result)
					}
				})
			},
			//提交
			submit(ruleForm) {
				this.$refs[ruleForm].validate((valid) => {
					if (valid) {
						this.ensureBtn = true
						if (this.isAddOrComp == 1) {
							this.oprationUintPub(1)
						} else {
							this.oprationUintPub(2)
						}
					} else {
						console.log('error submit!!');
						return false;
					}
				});
			},
			//关闭
			close(value) {
				let newValue = 2
				if (value) {
					newValue = value
				}
				this.$emit('detailMaskShow', newValue)
			},
			closeImg() {
				this.imgDialogShow = false
			},
		}
	}
</script>
<style scoped lang="less">
</style>
